﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Enterprise.Infrastructure;
using Enterprise.Model.BusiTravel;
using Enterprise.Service.BusiTravel;
namespace Enterprise.UI.Web.Modules.BusiTravel
{
    public partial class Close : Enterprise.Service.BasePage
    {
        string Id = (string)Utility.sink("Id", Utility.MethodType.Get, 0, 0, Utility.DataType.Str);
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OnStart();
            }
        }

        private void OnStart()
        {
           BusiTravelService bService = new BusiTravelService();
            var query = bService.BusiTravelDisp(Id);
            if (query != null)
            {
                tb_Subject.Text = query.BSUBJECT;
                tb_StartTime.Text = query.BSTARTIME.ToShortDateString();
                tb_EndTime.Text = query.BENDTIME.ToShortDateString();
            }
        }

        protected void Btn_Click(object sender, EventArgs e)
        {
            BusiTravelService bService = new BusiTravelService();
            var query = bService.BusiTravelDisp(Id);
            if (query != null)
            {
                query.DB_Option_Action = "Close";
                query.BENDTIME = (DateTime)Utility.sink(tb_EndTime.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Date);
                query.BCLOSE = 1;
                query.BCLOSETIME = DateTime.Now;
                string _note = "操作成功";
                try
                {
                    bService.BusiTravelExecute(query);
                }
                catch (Exception ex)
                {
                    _note = ex.Message;
                }

                Utility.ShowMsg(this.Page, "OK", this.Tran(_note), "Index.aspx");
            }
        }
    }
}